LG.resourceupdate = function (success)
{
    $(document).bind('keydown.resourcecreate', function (e)
    {
        if (e.keyCode == 13)
        {
            doAddFavorite();
        }
    });

    if (!window.resourceupdateWin)
    {
        var resourceupdatePanle = $("<form></form>");

        var resourceupdateTree = {
           
            url: 'sys/resource!update.shtml',
            checkbox: false,
            nodeWidth: 170
        };

        resourceupdatePanle.ligerForm({
            fields: [
                 { name:'UpdateResourceLevel', type: 'hidden',value:'1'},
                 { name:'UpdateResourceId',type:'hidden',value:actionNodeID},
                 { display: '菜单名称', name: 'UpdateResourceName', type: 'text', validate: { maxlength: 50, required: true, messages: { required: '请输入菜单名称'}} ,value:actionNodeName},
                 { display: "菜单图片", name: "UpdateResourceIcon",readOnly:true,  type: 'text',event:{name:'onfocus',value:'thisid ="UpdateResourceIcon" ;f_openIconsWin();'},value:actionNodeIcon}
                  ]
        });

        //验证
        jQuery.metadata.setType("attr", "validate");
        LG.validate(resourceupdatePanle);

        window.resourceupdateWin = $.ligerDialog.open({
           width: 350,
            height: 140, top: 200,
            isResize: true,
            title: '创建菜单',
            target: resourceupdatePanle,
            buttons: [
            { text: '确定', onclick: function ()
            {
                doAddFavorite();
            }
            },
            { text: '取消', onclick: function ()
            {
                window.resourceupdateWin.hide();
                $(document).unbind('keydown.resourceupdate');
            }
            }
            ]
        });
    }
    else
    {
        window.resourceupdateWin.show();
    }

    function doAddFavorite()
    { 
       var ResourceLevel = $("#UpdateResourceLevel").val();
       var ResourceName = $("#UpdateResourceName").val();
       var ResourceIcon = $("#UpdateResourceIcon").val();
        var ResourceId = $("#UpdateResourceId").val();
       
        if (resourceupdatePanle.valid())
        { 
            LG.ajax({
                url:'sys/resource!update.shtml',
                data: { resourceLevel: ResourceLevel, resourceName:ResourceName,resourceIcon:ResourceIcon,resourceId: ResourceId},
                success: function ()
                {
                    LG.showSuccess('修改成功');
                   
                    window.resourceupdateWin.hide();
                    //window.resourceupdateWin.close();
                    $(document).unbind('keydown.resourceupdate');
                  
                   treeSelect();
                    if (success)
                    {
                        success();
                    }
                },
                error: function (message)
                {
                    LG.showError(message);
                }
            });
        }

    }

};